package artin.a3d.model
{
	import alternativa.engine3d.core.Mesh;
	
	public class FaceModel extends Mesh
	{
		//顶点名字id
		public static  const  var VERTICESPREFIX:String="baseVertice"; 
		public static  const  var PLANEPREFIX:String="basePlane"; 
		public static  const  var SPPREFIX:String="baseObject"; 
		
		public function FaceModel(name:String=null)
		{
			super(name);
			trace(name);
			
			
		}
		
		publice Function FaceModel(name:String=null,vertexts:Array=null);{
			FaceModle(name);
			if(vertices.isEmpty()){
			//创建顶点
			createVertex(0, 0, 0, verticesPrefix + "_0");
			createVertex(0, 0, 5, verticesPrefix + "_1");
			createVertex(5, 5, 5, verticesPrefix + "_2");
			createVertex(5, 0, 0, verticesPrefix + "_3");
			createFace([VERTICESPREFIX+"_0",VERTICESPREFIX+"_1",VERTICESPREFIX+"_2",VERTICESPREFIX+"_3"],PLANEPREFIX+"_0");
			//把box bottom设置为绿色
			setMaterialToSurface(new WireMaterial(1, 0x00FF00), "box_bottom");
			
			}else{
			//创建点
			for(var i:int =0;i<vertices.length;i++)
				createVertex(vertices[i].x, vertices[i].y, vertices[i].z, verticesPrefix + "_"+i);
			
			//创建面
			for(var i:int =0;i<vertices.length;i++)
				
				createFace([VERTICESPREFIX+"_"+i*4,VERTICESPREFIX+"_"+(i*4+1),VERTICESPREFIX+"_"+(i*4+2),VERTICESPREFIX+"_"+(i*4+3)],PLANEPREFIX+"_"+i);
			}
		}
		
	}
}